//
//  XDownloadManager.h
//  DownloaderTest
//
//  Created by user on 2018/6/13.
//  Copyright © 2018年 Dnake. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "XDownloadModel.h"
#import "AFNetworking.h"

typedef NS_ENUM(NSInteger, HWDownloadState) {
    XDownloadStateDefault = 0,  // 默认
    XDownloadStateDownloading,  // 正在下载
    XDownloadStateWaiting,      // 等待
    XDownloadStatePaused,       // 暂停
    XDownloadStateFinish,       // 完成
    XDownloadStateError         // 错误
};

typedef void (^ProgressBlock)(CGFloat progress);

@interface XDownloadManager : NSObject

@property (nonatomic, strong, readonly) AFHTTPSessionManager *afSessionManager;

@property (nonatomic, strong) NSMutableDictionary *taskDict;

+ (instancetype)shareManager;

/**
 开始下载
 */
- (void)startDownloadTask:(XDownloadModel *)model ProgressBlock:(ProgressBlock)block;

// 暂停下载
- (void)pauseDownloadTask:(XDownloadModel *)model;

// 暂停下载
- (void)continueDownloadTask:(XDownloadModel *)model ProgressBlock:(ProgressBlock)block;

// 删除下载任务及本地缓存
- (void)deleteTaskAndCache:(XDownloadModel *)model;

// 下载时，杀死进程，更新所有正在下载的任务为等待
- (void)updateDownloadingTaskState;

// 重启时开启等待下载的任务
- (void)openDownloadTask;

@end
